namespace _2._17._2015_CodeFirst.Migrations
{
    using _2._17._2015_CodeFirst.Models;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<_2._17._2015_CodeFirst.Models.ContactsDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(ContactsDbContext context)
        {
            AddressType billing = new AddressType { Type = "Billing" };
            AddressType shipping = new AddressType { Type = "Shipping" };

            context.AddressTypes.AddOrUpdate(a => a.Type,
                billing,
                shipping);

            Name nick = new Name { FirstName = "Nick", LastName = "Brittain" };

            context.Names.AddOrUpdate(n => n.FirstName,
                nick
            );

            context.Addresses.AddOrUpdate(a => a.Street,
                new Address { Street = "111 Keyboard", City = "Houston", 
                    AddressType = billing, Name = nick, State = "TX",
                    Zip = "77833"});
        }
    }
}
